//在执行ajax、get、post之前会先执行ajaxPrefilter
$.ajaxPrefilter(options=>{
    options.url = 'http://api-breakingnews-web.itheima.net'+options.url
    if (options.url.indexOf('/my/') !== -1) {
        options.headers = {
            Authorization: sessionStorage.getItem('token') || ''
        }
    }
    // console.log(options.url);
    options.complete = function (res) {
        if (res.responseJSON.status === 1 && res.responseJSON.message === '身份认证失败！') {
            sessionStorage.removeItem('token');
            location.href = '/login.html';
        }
    }
})